package day16.ZiXi.TCP.LianXi02;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.UUID;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10000);
        while (true) {
            Socket acc = ss.accept();
            BufferedInputStream bis = new BufferedInputStream(acc.getInputStream());
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("D://"+ UUID.randomUUID().toString()+"11.jpg"));
            int b;
            while ((b = bis.read()) != -1) {
                bos.write(b);
            }
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(acc.getOutputStream()));
            bw.write("YES");
            bw.newLine();
            bw.flush();

            bos.close();
            acc.close();
        }
        //ss.close();
    }
}
